<?php

	session_start();
	$username = $_SESSION['username'];
	$id = $_SESSION['id'];
	

?>

<head>
	<link rel="stylesheet" type="text/css" href="profile_inner.css" />

</head>

<?php

	//edit the user's profile
	
	require_once "../common/PinSQL.obj";
	$pinSQL = new pinSQL();
	
	$pinSQL->Query("SELECT * FROM privacy WHERE id='$id'");
	
	$row = $pinSQL->FetchNextRow();
	
	$postbuzz = $row['postbuzz'];
	$postpicture = $row['postpicture'];
	$postsong = $row['postsong'];
	$postvideo = $row['postvideo'];
	$postgame = $row['postgame'];
	$postblog = $row['postblog'];
	$ratepicture = $row['ratepicture'];
	$ratesong = $row['ratesong'];
	$ratevideo = $row['ratevideo'];
	$rategame = $row['rategame'];
	$rateblog = $row['rateblog'];
	$commentpicture = $row['commentpicture'];
	$commentsong = $row['commentsong'];
	$commentvideo = $row['commentvideo'];
	$commentgame = $row['commentgame'];
	$commentblog = $row['commentblog'];
	$profilechanges = $row['profilechange'];
	
	
	
?>

<img src="/img/icons/back.gif"><a href="frame.php?page=profile"> Return to profile </a>

<div class="padded_text">
	<div class="head"><img src="/img/icons/privacy.gif" /> Edit Privacy Settings</div>
	
	<div class="horizontal_separation"></div>
	note: only users who have tagged you will be able to see your user notifications.  You can specify which actions will generate notifications, and you can block certain users from tagging you using the form below.
	
	<a name="postcontent"></a>
	<p /><div class="subhead">Posting Content</div>
	
	notify users when I have ...
	<table>
	<tbody>
		<tr><td><input type="checkbox" <?php if ($postpicture){ echo 'checked'; } ?> id="postpicture" /> ...posted a picture &nbsp<img src="../img/icons/update_new_picture.png" style="height: 16px; width: 16px;" /></td></tr>
		<tr><td><input type="checkbox" <?php if ($postsong){ echo 'checked'; } ?> id="postsong" /> ...posted a song &nbsp<img src="../img/icons/update_new_song.png" style="height: 16px; width: 16px;" /></td></tr>
			<!--<td><input type="checkbox" <?php if ($postvideo ? 'true' : 'false'); ?>" id="postvideo" /> Posted a video</td>
			<td><input type="checkbox" <?php if ($postgame){ echo 'checked'; } ?> id="postgame" /> Posted a game</td>!-->
		<tr><td><input type="checkbox" <?php if ($postblog){ echo 'checked'; } ?> id="postblog" /> ...posted a blog &nbsp<img src="../img/icons/update-new-entry.png" style="height: 16px; width: 16px;" /></td></tr>
	</tbody>
	</table>
	
	<a name="ratecontent"></a>
	<p /><div class="subhead">Rating Content</div>
		
	notify users when I have ...
	<table>
	<tbody>
		<tr><td><input type="checkbox" <?php if ($ratepicture){ echo 'checked'; } ?> id="ratepicture" /> ...rated a picture &nbsp<img src="../img/icons/update_rating_picture.png" style="height: 16px; width: 16px;" /></td></tr>
		<tr><td><input type="checkbox" <?php if ($ratesong){ echo 'checked'; } ?> id="ratesong" /> ...rated a song &nbsp<img src="../img/icons/update_rating_song.png" style="height: 16px; width: 16px;" /></td></tr>
			<!--
			<td><input type="checkbox" <?php if ($postvideo ? 'true' : 'false'); ?>" id="postvideo" /> Posted a video</td>
			<td><input type="checkbox" <?php if ($postgame ? 'true' : 'false'); ?>" id="postgame" /> Posted a game</td>
			!-->
		<tr><td><input type="checkbox" <?php if ($rateblog){ echo 'checked'; } ?> id="rateblog" /> ...rated a blog &nbsp<img src="../img/icons/update-new-entry.png" style="height: 16px; width: 16px;" /></td></tr>
	</tbody>
	</table>
	
	<a name="commentcontent"></a>
	<p /><div class="subhead">Commenting on Content</div>
	
	notify users when I have ...
	<table>
	<tbody>
		<tr><td><input type="checkbox" <?php if ($commentpicture){ echo 'checked'; } ?> id="commentpicture" /> ...commented on a picture &nbsp<img src="../img/icons/update-new-picture-comment.png" style="height: 16px; width: 16px;" /></td></tr>
		<tr><td><input type="checkbox" <?php if ($commentsong){ echo 'checked'; } ?> id="commentsong" /> ...commented on a song &nbsp<img src="../img/icons/update-new-song-comment.png" style="height: 16px; width: 16px;" /></td></tr>
			<!--
			<td><input type="checkbox" <?php if ($postvideo ? 'true' : 'false'); ?>" id="postvideo" /> Posted a video</td>
			<td><input type="checkbox" <?php if ($postgame ? 'true' : 'false'); ?>" id="postgame" /> Posted a game</td>
			!-->
		<tr><td><input type="checkbox" <?php if ($commentblog){ echo 'checked'; } ?> id="commentblog" /> ...commented on a blog &nbsp<img src="../img/icons/update-new-entry.png" style="height: 16px; width: 16px;" /></td></tr>
	</tbody>
	</table>
	
	<a name="otherchanges"></a>
	<p /><div class="subhead">Other</div>
	
	notify users when I have ...
	<table>
	<tbody>
		<tr><td><input type="checkbox" <?php if ($postbuzz){ echo 'checked'; } ?> id="postbuzz" /> ...posted a buzz &nbsp<img src="../img/icons/update-new-buzz.png" style="height: 16px; width: 16px;" /></td></tr>	
		<tr><td><input type="checkbox" <?php if ($profilechanges){ echo 'checked'; } ?> id="profilechanges" /> ...made a change to my profile &nbsp<img src="../img/icons/update-profile-edit.png" style="height: 16px; width: 16px;" /></td></tr>
	</tbody>	
	</table>
	
	<input type="hidden" id="id" value="<?php echo $id; ?>" />
	<div class="horizontal_separation"></div>
	
	<span id="confirmation1" class="redtext" style="display:none;"><img src="/img/ajax_sm.gif" /> Updating...</span>
	<input type="button" value="Update" class="inputFieldR" onclick="update();" />
		
		
	<script type="text/javascript">

	function update()
	{
	
	
		var postpicture = document.getElementById('postpicture').checked * 1;
		
		var postsong = document.getElementById('postsong').checked * 1;
		var postblog = document.getElementById('postblog').checked * 1;
		
		var ratepicture = document.getElementById('ratepicture').checked * 1;
		var ratesong = document.getElementById('ratesong').checked * 1;
		var rateblog = document.getElementById('rateblog').checked * 1;
		
		var commentpicture = document.getElementById('commentpicture').checked * 1;
		var commentsong = document.getElementById('commentsong').checked * 1;
		var commentblog = document.getElementById('commentblog').checked * 1;
		
		var postbuzz = document.getElementById('postbuzz').checked * 1;
		var profilechanges = document.getElementById('profilechanges').checked * 1;
		
		var id = document.getElementById('id').value;
		
		document.getElementById('confirmation1').style.display = 'block';
		document.getElementById('confirmation1').innerHTML = '<img src="/img/ajax_sm.gif" /> Updating...';
		
		// create the XMLHttpRequest object
		var request;
		try { request = new XMLHttpRequest(); }
		catch(e)
		{
			try { request = new ActiveXObject("Msxml2.XMLHTTP"); }
		   	catch(e)
		   	{
		      	try { request = new ActiveXObject("Microsoft.XMLHTTP"); }
		        	catch(e)
		        	{
		          	alert("Your browser will falset support this webpage.");
		             	return 'false';
		        	}
		   	}
		}
		
		request.open("POST", 'updateprivacy.php', 'true');
		
		request.onreadystatechange = function()
		{
			if (request.readyState == 4)
			{
				
		      	document.getElementById('confirmation1').innerHTML = "Updated!";
		      
		   	}
		}

		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		request.send('id=' + id + 
							'&postpicture=' + postpicture +
							'&postsong=' + postsong +
							'&postblog=' + postblog +
							'&ratepicture=' + ratepicture +
							'&ratesong=' + ratesong +
							'&rateblog=' + rateblog +
							'&commentpicture=' + commentpicture +
							'&commentsong=' + commentsong +
							'&commentblog=' + commentblog +
							'&postbuzz=' + postbuzz +
							'&profilechanges=' + profilechanges); 
					
							
							
	}
		
		

	</script>